<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="/struts-tags" prefix="s"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/style.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath }/jq/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/layer/layer.js"></script>
<script type="text/javascript">
	$(function() {
		$(".delete").click(function() {
			var str = this.lang.split("!");
			if (!confirm("您真的要删除[" + str[0] + "]这张照片吗？")) {
				return;
			}
			$.post("${pageContext.request.contextPath }/picture/delete", {
				"picture.id" : str[1]
			}, function(data) {
				location.href("${pageContext.request.contextPath }/user/list");
			});
		});

		$(".display").click(function() {
			$.getJSON("${pageContext.request.contextPath }/picture/getpic", {
				"picture.id" : this.lang,
				"idType" : "picture"
			}, function(data) {
				layer.photos({
					//		html:"",
					photos : data

				});
			});

		});

	});
</script>


</head>
<body>
	修改用户信息
	<form action="user/save" method="post">
		<table width="244">
			<tr>
				<td width="64">用户名</td>
				<td width="168"><input type="text" name="user.userName"
					id="userName" readonly value="<s:property value='user.userName'/>">
				</td>
			</tr>
			<tr>
				<td>密码</td>
				<td><input type="text" name="user.pwd" id="pwd"
					value="<s:property value='user.pwd'/>"></td>
			</tr>
			<tr>
				<td colspan="2"><input type="hidden" name="user.id"
					value="<s:property value='user.id'/>"> <input type="submit"
					name="btn" id="btn" value="提交"></td>
			</tr>
		</table>
	</form>
	<br />
	<br />
	<s:if test="%{#PICTURE.size>0}">
显示用户的所有照片
<table class="bordered">
			<thead>
				<tr>
					<th>序号</th>
					<th>照片名称</th>
					<th>显示</th>
					<th>删除</th>
				</tr>
			</thead>
			<s:iterator value="#PICTURE" status="st" id="p">
				<tr>
					<td><s:property value="#st.index+1" /></td>
					<td><s:property value="#p.name" /></td>
					<td><a href="#" class="display"
						lang="<s:property value='#p.id'/>">显示</a></td>
					<td><a href="#" class="delete"
						lang="<s:property value='#p.name'/>!<s:property value='#p.id'/>">删除</a></td>
				</tr>
			</s:iterator>
		</table>
	</s:if>
	<br />
	<br /> 上传照片
	<form action="${pageContext.request.contextPath }/picture/add"
		method="post" enctype="multipart/form-data">
		<table>
			<tr>
				<td>选择照片</td>
				<td><input type="file" name="image"></td>
			</tr>
			<tr>
				<td>照片名称</td>
				<td><input type="text" name="pictures[0].name"> <input
					type="hidden" name="pictures[0].uid"
					value="<s:property value='user.id'/>"></td>
			</tr>

			<tr>
				<td>选择照片</td>
				<td><input type="file" name="image"></td>
			</tr>
			<tr>
				<td>照片名称</td>
				<td><input type="text" name="pictures[1].name"> <input
					type="hidden" name="pictures[1].uid"
					value="<s:property value='user.id'/>"></td>
			</tr>

			<tr>
				<td>选择照片</td>
				<td><input type="file" name="image"></td>
			</tr>
			<tr>
				<td>照片名称</td>
				<td><input type="text" name="pictures[1].name"> <input
					type="hidden" name="pictures[3].uid"
					value="<s:property value='user.id'/>"></td>
			</tr>

			<tr>
				<td colspan="2"><input type="submit" value="提交"></td>
			</tr>

		</table>
	</form>
	<a href="${pageContext.request.contextPath }/main.jsp">返回主页面</a>
</body>
</html>